package main

import (
	"fmt"
	"os/exec"
	"strings"
)

func main() {
	// 获取设备名称
	deviceName, err := getDeviceName()
	if err != nil {
		fmt.Println("Error getting device name:", err)
		return
	}

	// 获取处理器信息
	processorInfo, err := getProcessorInfo()
	if err != nil {
		fmt.Println("Error getting processor info:", err)
		return
	}


	// 获取设备ID
	deviceID, err := getDeviceID()
	if err != nil {
		fmt.Println("Error getting device ID:", err)
		return
	}

	// 获取操作系统信息
	osInfo, err := getOSInfo()
	if err != nil {
		fmt.Println("Error getting OS info:", err)
		return
	}

	// 打印设备信息
	fmt.Println("设备名称:", deviceName)
	fmt.Println("处理器:", processorInfo)
	fmt.Println("设备ID:", deviceID)
	fmt.Println("操作系统信息:", osInfo)
}

// 获取设备名称
func getDeviceName() (string, error) {
	out, err := exec.Command("hostname").Output()
	if err != nil {
		return "", err
	}
	return strings.TrimSpace(string(out)), nil
}

// 获取处理器信息
func getProcessorInfo() (string, error) {
	out, err := exec.Command("wmic", "cpu", "get", "name").Output()
	if err != nil {
		return "", err
	}
	return strings.TrimSpace(string(out)), nil
}


// 获取设备ID
func getDeviceID() (string, error) {
	out, err := exec.Command("wmic", "csproduct", "get", "uuid").Output()
	if err != nil {
		return "", err
	}
	return strings.TrimSpace(string(out)), nil
}

// 获取操作系统信息
func getOSInfo() (string, error) {
	out, err := exec.Command("wmic", "os", "get", "Caption,OSArchitecture").Output()
	if err != nil {
		return "", err
	}
	return strings.TrimSpace(string(out)), nil
}
